package com.example.shaidemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;

import java.util.ArrayList;
import java.util.List;

public class CarMenuActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_car_menu);

        GridView listView = (GridView) findViewById(R.id.car_view);
        List<String> cityName = new ArrayList<>();
        String[] city = new String[]{"成都", "杭州", "重庆", "武汉", "苏州", "西安", "天津", "南京", "郑州",
                "长沙", "沈阳", "青岛", "宁波", "东莞", "无锡"};
        for(int i=0;i<city.length;i++){
            cityName.add(city[i]);
        }

        ArrayAdapter adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,cityName);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }
}